#!/bin/sh
#
cd /usr/local/share/cacti/cli
if [ $# -lt 1 ]
then
	echo "usage: $0 apNN [ip]"
	exit
fi
host=$1
if [ $# -gt 1 ]
then
	ip=$2
else
	ip=$host
fi
cisco_router=`php add_device.php --list-host-templates | awk '/Cisco Router$/ {print $1}'`
if php add_device.php --description=$host --ip=$ip --template=$cisco_router --version=3 --username=netdisco --password="Disco stu does not advertise." --authproto=SHA --privproto='[None]' --avail=snmp
then
	id=`php add_graphs.php --list-hosts | awk "\\$2 == \"$host\" {print \\$1}"`
	echo Hostname $host Cacti ID $id
	# Cisco CPU utilization
	php add_graphs.php --graph-type=cg --graph-template-id=18 --host-id=$id
	# Add per-interface graphs
	/home/fenner/src/pupu/netdisco2cacti/gadd-both $id
fi
